# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def menu_principal
    @menu =%w( Motorista Veiculo operacoes user )
    menu_principal ="<div>"
    menu_principal << "<ul id='menu_dropdown' class='menubar'>" 
    @menu.each do |item|
      if item == "Veiculo"
        menu_principal << "<li class='submenu'><div>" + link_to("<span>Veiculo</span>",:controller =>item.pluralize) + "</div></li>"
      end
       if item == "Motorista"
        menu_principal << "<li class='submenu'><div>" + link_to("<span><img align='left' src='/images/Profile.png' alt='Motorista'/>Motorista</span>",:controller =>item.pluralize) + "</div></li>"
      end
      if item == "operacoes"
        menu_principal << "<li class='submenu'><div><a href='#'><span>Operações</span></a><div>"
        menu_principal << "<ul class='menu'>"
        menu_principal << "<li><div>" + link_to("<span>Ipem Prefeitura</span>",:controller =>"ipem_prefeituras", :class =>"right") + "</div></li>"
        menu_principal << "<li><div>" + link_to("<span>Subtu Prefeitura</span>",:controller =>"subtu_prefeituras",:class =>"right") + "</div></li>"
        menu_principal << "<li><div>" + link_to("<span>DutDetran Prefeitura</span>",:controller =>"dut_detran_prefeituras",:class =>"right") + "</div></li>"
        menu_principal << "</ul></li>"
        menu_principal << "<script>horizontal();</script>" 
      end
      if item == "user"
        menu_principal << "<li class='submenu'><div>" + link_to("<span>Usuário</span>",:controller =>"users") + "</div></li>"
      end
    end
    menu_principal << "<li class='submenu' ><a href='../account/logout' class='right'><span><img align='left' src='/images/sos.gif' alt='Sair'/> Sair</span>  </a></li>"
    menu_principal << "</ul>"
    menu_principal << "</div>"
    menu_principal
  end
  
  def self.foreign_key(from_table, from_column, to_table)
    #constraint_name = "fk_#{from_table}_#{from_column}"
    #execute %{alter table #{from_table}
    #          add constraint #{constraint_name}
    #          foreign key (#{from_column})
    #          references #{to_table}(id)}
  end
end



